<!--<link href="/static/css/plugins/treeview/bootstrap-treeview.css" rel="stylesheet">-->
<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <!--<div class="ibox-title">-->
                <!--<h5>类别管理-{$typeName}</h5>-->
                <!--<div class="ibox-tools">-->

                <!--</div>-->
            <!--</div>-->
            <div class="ibox-content">

                <div class="row">
                    <div class="col-sm-12">
                        <div class="ibox float-e-margins">
                            <div class="ibox-title">
                                <h5>默认</h5>
                                <div class="ibox-tools">
                                    <a class="collapse-link">
                                        <i class="fa fa-chevron-up"></i>
                                    </a>
                                    <a class="dropdown-toggle" data-toggle="dropdown" href="buttons.html#">
                                        <i class="fa fa-wrench"></i>
                                    </a>
                                    <ul class="dropdown-menu dropdown-user">
                                        <li><a href="buttons.html#">新增子节点</a></li>
                                        <li><a href="buttons.html#">关联后台类目</a></li>
                                        <li><a href="buttons.html#">删除所选</a></li>
                                    </ul>
                                    <a class="close-link">
                                        <i class="fa fa-times"></i>
                                    </a>
                                </div>
                            </div>
                            <div class="ibox-content">
                                <div id="treeview" class="test"></div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>

</div>

<!-- Bootstrap-Treeview plugin javascript -->
<script src="/static/js/plugins/treeview/bootstrap-treeview.js"></script>
<script>
    $.get('/category/getTabelData',function(res){
        if(res.code==1){
            tableData = res.data;
            tableData.map(function(first){
                first.text = first.title
                first.nodes.map(function(second){
                    second.text = second.title
                    second.nodes.map(function(third){
                        third.text = third.title
                    })
                })
            })

            console.log(tableData);
            $('#treeview').treeview({
                data: tableData,
                onNodeSelected: function (event, node) {
                    console.log('您单击了 ' + node.text);
                }
            });
            $('#treeview').treeview('collapseAll', { silent: true });
        }
    })
</script>
<script>
    var defaultData = [
        {
            text: '父节点 1',
            href: '#parent1',
            tags: ['4'],
            nodes: [
                {
                    text: '子节点 1',
                    href: '#child1',
                    tags: ['2'],
                    nodes: [
                        {
                            text: '孙子节点 1',
                            href: '#grandchild1',
                            tags: ['0']
                        },
                        {
                            text: '孙子节点 2',
                            href: '#grandchild2',
                            tags: ['0']
                        }
                    ]
                },
                {
                    text: '子节点 2',
                    href: '#child2',
                    tags: ['0']
                }
            ]
        },
        {
            text: '父节点 2',
            href: '#parent2',
            tags: ['0']
        },
        {
            text: '父节点 3',
            href: '#parent3',
            tags: ['0']
        },
        {
            text: '父节点 4',
            href: '#parent4',
            tags: ['0']
        },
        {
            text: '父节点 5',
            href: '#parent5',
            tags: ['0']
        }
    ];
    // $('#treeview1').treeview({
    //     data: defaultData
    // });


    var json = '[' +
        '{' +
        '"text": "父节点 1",' +
        '"nodes": [' +
        '{' +
        '"text": "子节点 1",' +
        '"nodes": [' +
        '{' +
        '"text": "孙子节点 1"' +
        '},' +
        '{' +
        '"text": "孙子节点 2"' +
        '}' +
        ']' +
        '},' +
        '{' +
        '"text": "子节点 2"' +
        '}' +
        ']' +
        '},' +
        '{' +
        '"text": "父节点 2"' +
        '},' +
        '{' +
        '"text": "父节点 3"' +
        '},' +
        '{' +
        '"text": "父节点 4"' +
        '},' +
        '{' +
        '"text": "父节点 5"' +
        '}' +
        ']';

    // $('#treeview12').treeview({
    //     data: json
    // });
</script>
<script src="/static/js/demo/treeview-demo.js"></script>

<!-- 自定义js -->
<script src="/static/js/content.js?v=1.0.0"></script>
